package com.itqf.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.stereotype.Component;

/**
 * projectName: springframeworkgp8
 *
 * @author: 赵伟风
 * time: 2021/8/4 11:52
 * description:
 */
@Component("tAdvice")
public class TranscationAdvice {


    public void throwing(){

        System.out.println("事务回滚!");
    }


    /**
     * 环绕增强,返回值必须是object
     * @param joinPoint 参数必须传入 ProceedingJoinPoint
     * @return
     */
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {

        System.out.println("开启事务");
        Object ret = joinPoint.proceed();
        //后置,不报错执行
        System.out.println("事务提交");

        return ret;
    }



}
